<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <link rel="stylesheet" href="/shop/style/css/ch-ui.admin.css">
    <link rel="stylesheet" href="/shop/style/font/css/font-awesome.min.css">
    <script type="text/javascript" src="/shop/style/js/jquery.js"></script>
    <link rel="stylesheet" href="/houtai/layui/css/layui.css">
    <script src="/houtai/layui/layui.js"></script>
    <script type="text/javascript" src='/houtai/layui/jquery-3.2.1.js'></script>
</head>
<body>
<!--面包屑导航 开始-->
<div class="crumb_warp">
    <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
    <i class="fa fa-home"></i> <a href="#">首页</a> &raquo; 修改密码
</div>
<!--面包屑导航 结束-->

<!--结果集标题与导航组件 开始-->
<div class="result_wrap">
    <div class="result_title">
        <h3>修改密码</h3>
    </div>
</div>
<!--结果集标题与导航组件 结束-->

<div class="result_wrap">
    <form action="javascript:;" id="login_form" method="post">
        <input type="hidden" name="_token" value="{{csrf_token()}}">
        <table class="add_tab">
            <tbody>
            <tr>
                <th width="120"><i class="require">*</i>原密码：</th>
                <td>
                    <input type="password" name="password_o" id="pass_o"> </i>请输入原始密码</span>
                </td>
            </tr>
            <tr>
                <th><i class="require">*</i>新密码：</th>
                <td>
                    <input type="password" name="password" id="pass_n"> </i>新密码6-20位</span>
                </td>
            </tr>
            <tr>
                <th><i class="require">*</i>确认密码：</th>
                <td>
                    <input type="password" name="password_c" id="pass_n_g"> </i>再次输入密码</span>
                </td>
            </tr>
            <tr>
                <th></th>
                <td>
                    <input type="submit" value="提交">
                    <input type="button" class="back" onclick="history.go(-1)" value="返回">
                </td>
            </tr>
            </tbody>
        </table>
    </form>

    <script type="text/javascript">
        $(function(){
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });

            $("#login_form").submit(function(){
                var pass_o= $("#pass_o").val();
                var pass_n = $("#pass_n").val();
                var pass_n_g = $("#pass_n_g").val();
                layui.use('layer', function(){
                    if(pass_o == ''){
                        layer.msg('请输入原密码');
                        return false;
                    }
                    if(pass_n == ''){
                        layer.msg('请输入新密码');
                        return false;
                    }
                    if(pass_n_g == ''){
                        layer.msg('请输入确认新密码');
                        return false;
                    }
                    if(pass_n_g != pass_n){
                        layer.msg('请确认2次密码输入一致');
                        return false;
                    }
                    $.ajax({
                        url:"{{url('shop/edit_pass')}}",
                        type: 'post',
                        data: {pass_o:pass_o,pass_n:pass_n,pass_n_g:pass_n_g},
                        dataType: 'json',

                        success:function(data){
                            if(data['code'] == 1){
                                {{--  跳转到首页  --}}
                                    window.location.href = "{{url('shop/home') }}";
                            }else{
                                layer.msg(data['msg']);
                            }
                        },
                        error:function(){
                            alert("系统正忙");
                        }
                    })
                });



            })
        })
    </script>
</div>
</body>
</html>